
import java.util.Timer;
import javax.microedition.lcdui.Image;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import javax.microedition.lcdui.game.Sprite;

/**
 *
 * @author pdb
 */
public class Coin {
    //Voor de question block
    private Sprite coin;
    private int CoinDelay = 150;
    private int[] CoinAnimationSequence = {0, 1, 2};
    private SpriteAnimationTask sprCoin;
    private Timer timer1;
    private int UpdateCount = 0;
    
    public Coin() {
        //Laad de plaatjes
        LoadGraphics grCoin = new LoadGraphics();
        this.coin = grCoin.getSprite_Coin(CoinAnimationSequence);
        this.sprCoin = new SpriteAnimationTask(getCoin(), true);
        this.sprCoin.setMoving(true);
        this.timer1 = new Timer();
        this.timer1.scheduleAtFixedRate(sprCoin, 0, CoinDelay);
    }
    
    /**
     * Updates the position of the coin, first up by 5, then down by 3, after
     * 9 updates it's done
     * @return True if done with the animation, else false
     */
    public boolean MoveCoin() {
        if (UpdateCount < 10) {
            this.coin.setPosition(this.coin.getX(), this.coin.getY() - 8); 
        } else if (UpdateCount < 15) {
            this.coin.setPosition(this.coin.getX(), this.coin.getY() + 8);
        } else {
            return true;
        }
        
        //Increment counter, indicate not done yet
        UpdateCount++;
        return false;
    }

    public void UpdateCoin() {
        this.coin.nextFrame();
    }
    public Sprite getCoin() {
        return coin;
    }

    public void setCoin(Sprite coin) {
        this.coin = coin;
    }
}
